		TITLE	PE_CHANG - Copyright (c) SLR Systems 1994

		INCLUDE	MACROS
if	fg_pe
		INCLUDE	PE_STRUC

		PUBLIC	CHANGE_PE_OBJECT


		.DATA

		EXTERNDEF	CURN_PE_OBJECT_NUMBER:DWORD,CURN_PE_OBJECT_GINDEX:DWORD,PE_DEBUG_OBJECT_NUMBER:DWORD
		EXTERNDEF	FINAL_HIGH_WATER:DWORD,OLD_HIGH_WATER:DWORD,PE_BASE:DWORD,FIRST_PEOBJECT_GINDEX:DWORD

		EXTERNDEF	PE_OBJECT_GARRAY:STD_PTR_S


		.CODE	PASS2_TEXT

		EXTERNDEF	DO_OS2_ALIGN:PROC


CHANGE_PE_OBJECT	PROC
		;
		;FIRST, CLOSE OUT CURRENT OBJECT
		;
		MOV	EAX,CURN_PE_OBJECT_NUMBER
		MOV	ECX,PE_DEBUG_OBJECT_NUMBER

		TEST	EAX,EAX
		JZ	L2$

		CMP	ECX,EAX
		JZ	L3$
L2$:
		CALL	DO_OS2_ALIGN		;ALIGN TO ALIGNMENT FILE BOUNDARY

		MOV	EAX,CURN_PE_OBJECT_GINDEX

		TEST	EAX,EAX
		JZ	L7$
L6$:
		CONVERT	EAX,EAX,PE_OBJECT_GARRAY
		ASSUME	EAX:PTR PE_IOBJECT_STRUCT

		MOV	EDX,FINAL_HIGH_WATER
		MOV	ECX,[EAX]._PEOBJECT_POFFSET

		SUB	EDX,ECX

		MOV	[EAX]._PEOBJECT_PSIZE,EDX
L4$:
		MOV	EAX,[EAX]._PEOBJECT_NEXT_GINDEX
L5$:
		MOV	CURN_PE_OBJECT_GINDEX,EAX
		MOV	EDX,FINAL_HIGH_WATER

		TEST	EAX,EAX
		JZ	L9$

		CONVERT	EAX,EAX,PE_OBJECT_GARRAY
		ASSUME	EAX:PTR PE_IOBJECT_STRUCT

		MOV	[EAX]._PEOBJECT_POFFSET,EDX
		MOV	EDX,[EAX]._PEOBJECT_RVA

		ADD	EDX,PE_BASE
		MOV	ECX,[EAX]._PEOBJECT_NUMBER

		MOV	OLD_HIGH_WATER,EDX
		MOV	CURN_PE_OBJECT_NUMBER,ECX
L9$:
		RET

L7$:
		MOV	EAX,FIRST_PEOBJECT_GINDEX
		JMP	L5$

L3$:
		MOV	EAX,CURN_PE_OBJECT_GINDEX

		CONVERT	EAX,EAX,PE_OBJECT_GARRAY
		ASSUME	EAX:PTR PE_IOBJECT_STRUCT

		JMP	L4$

CHANGE_PE_OBJECT	ENDP

endif

		END

